{extend name="layout/datagrid" /}
{block name="content_header"}        
<h1>
    网站设置
    <small>advanced tables</small>
</h1>
<ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
    <li><a href="#">系统</a></li>
    <li class="active">网站设置</li>
</ol>
{/block}
{block name="content"}
<div class="box">
    <div class="box-header">
        <ul class="nav nav-tabs">
            {foreach name="$tabs" item="vo"}
            <li class=""><a href="#">{$key}</a></li>
            {/foreach}
        </ul>
    </div>
    <!-- /.box-header -->
    <div class="box-body">
        <div class="row">
            <div class="col-md-8">
                <!-- form start -->
                <form action="{:url('save_edit')}" method="post" class="form-horizontal">
                    <div class="box-body">
                        {foreach name="$tabs" item="vo"}
                        <div class="tab-content" style="display:none">
                            {foreach name="$vo" item="vo2"}
                            <div class="form-group">
                                <label class="col-sm-3 control-label">{$vo2.conf_title}</label>
                                <div class="col-sm-9">
                                    {switch $vo2['input_type']}
                                    {case textarea}
                                    <textarea name="{$vo2['conf_name']}" class="form-control input-sm" placeholder="{$vo2['conf_title']}" cols="60" rows="3">{$vo2['conf_value']}</textarea>
                                    {/case}
                                    {case image}
                                    <div class="input-group">
                                        <input type="text" name="{$vo2['conf_name']}" class="form-control input-sm"  placeholder="{$vo2['conf_title']}" value="{$vo2['conf_value']??''}">
                                        <span class="input-group-btn">
                                            <a href="{:url('uploader/delete')}" class="btn btn-sm btn-default btn-sm xsui-btn-singlefile-delete-image" title="删除图片">删除</a>
                                            <a href="{:url('uploader/single_file','name='.$vo2['conf_name'])}" class="btn btn-sm btn-default btn-sm xsui-btn-singlefile-uploader-image" title="选择图片并上传">上传</a>
                                            <a href="{$vo2['conf_value']??''}" class="btn btn-sm btn-default btn-sm" target="_blak">预览</a>
                                        </span>
                                    </div>
                                    {/case}
                                    {case combobox}
                                    {:xsfn_html_combobox($vo2['conf_name'],$vo2['preset_data'],$vo2['conf_value'],$vo2['is_required'])}
                                    {/case}
                                    {default /}
                                    <input type="text" name="{$vo2['conf_name']}" class="form-control input-sm" placeholder="{$vo2['conf_title']}" value="{$vo2['conf_value']??''}" />
                                    {/switch}
                                </div>
                            </div>
                            {/foreach}
                        </div>
                        {/foreach}
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <button type="button" class="btn btn-sm btn-default xsui-btn-close-dialog">取消</button>
                        <button type="submit" class="btn btn-sm btn-primary pull-right">保存</button>
                    </div>
                    <!-- /.box-footer -->
                </form>
            </div>
        </div>
    </div>
    {/block}
    {block name="script_before"}
    <script>
        // 2018-4-21
        $('.nav-tabs a').click(function () {
            var $a = $(this);
            var id = $('.nav-tabs a').index($a);
            $a.parent().addClass('active').siblings().removeClass('active');
            $('.tab-content').hide().eq(id).show();
            return false;
        })
        $('.nav-tabs a:eq(0)').trigger('click');
        xsApp.xsfnUploadButtonInit();
        /**
         * 单文件上传回调函数
         * @param {type} name
         * @param {type} value
         * @returns {undefined}
         * @version 1.0 2016-12-15
         */
        function single_uploader_cb(name, value) {
            var $input = $('[name="' + name + '"]');
            $input.val(value)
            //$input.parent().parent().find('img').attr('src', value).parent().attr({'href': value, 'title': value}).next().data('url', value);
            layer.closeAll();
            //$('iframe').parent().dialog('close');
        }
    </script>
    {/block}